<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <script src="vue3.js"></script>
        <script src="https://unpkg.com/axios@1.6.8/dist/axios.min.js"></script>
    </head>
    <body>
        <div id="app">
            <button @click="getData">获取接口数据</button>
            <div>
                {{result}}
            </div>
        </div>
        <script>
        const service = axios.create({
            baseURL:"http://127.0.0.1:8899",
            timeout:6000
        });   
        const {createApp} = Vue;
        var v = createApp({
          data(){
            return {
              result:null
            }
          },
          methods:{
            getData(){
              let self = this;
              //从接口获取数据
              service.get("/hello")
              .then(res=>{
                 self.result = res.data
              })
              .catch(err=>{
 
              })
              //后面的代码




            }
          }
        }).mount("#app")
        </script>
    </body>
</html>